import store from "../store/store"

export function conversionPagePermission(data){
    //首先过滤掉没有权限的页面
    const newdata=data.filter(item=>item.pagePermissions.length!=0)
    const permission=store.state.user.PagePermission
    //每个页面权限转化为二进制格式
    newdata.forEach((element,i) => {
       let temp=""
       permission.forEach(item=>{
           if(element.pagePermissions.includes(item)){
               temp+="1"
           }else{
               temp+='0'
           }
       })
       //再将二进制转化为10进制的数字
       newdata[i].pagePermissions=parseInt(temp,2);
    });
    return newdata;
}
export function MathConver(data){
   return data.toString(2)
}
